package com.homedo.microservice.open.service.gateway.alert;

import com.homedo.microservice.open.service.gateway.alert.util.ApplicationContextUtil;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;


@Configuration
@SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
@EnableScheduling
public class OpenServiceGatewayAlertApplication extends SpringBootServletInitializer implements ApplicationContextAware {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(OpenServiceGatewayAlertApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(OpenServiceGatewayAlertApplication.class).properties("spring.config.location:/data/appdatas/gateway-alert/conf.properties");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        ApplicationContextUtil.setApplicationContext(applicationContext);
    }
}
